package com.ityueqiangu.portal.conroller;

import com.ityueqiangu.core.enums.CommonEnum;
import com.ityueqiangu.core.enums.SysFlagStatusEnum;
import com.ityueqiangu.core.web.controller.BaseController;
import com.ityueqiangu.core.web.result.DataGridResultInfo;
import com.ityueqiangu.project.exhibitionInfo.domain.ExhibitionInfo;
import com.ityueqiangu.project.exhibitionInfo.service.IExhibitionInfoService;
import com.ityueqiangu.project.galleryinfo.domain.GalleryInfo;
import com.ityueqiangu.project.galleryinfo.service.IGalleryInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Clever、xia
 * @title: FrontExhibitionInfoController
 * @projectName art-exhibition-system
 * @description:
 * @date 2021-03-16 20:26
 */
@Controller
@RequestMapping(value = "/portal/exhibitionInfo")
public class FrontExhibitionInfoController extends BaseController {

    @Autowired
    private IGalleryInfoService galleryInfoService;
    @Autowired
    private IExhibitionInfoService exhibitionInfoService;

    /**
     * 获取展览馆信息
     * @param id
     * @param mmap
     * @return
     */
    @RequestMapping()
    public String exhibitionInfo(Integer id,ModelMap mmap){
        GalleryInfo galleryInfo = galleryInfoService.selectGalleryInfoById(id);
        mmap.addAttribute("galleryInfo",galleryInfo);
        return "portal/exhibition";
    }

    /**
     * 获取展览信息
     * @param id
     * @param mmap
     * @return
     */
    @RequestMapping(value = "/exhibitionDetail")
    public String exhibitionDetail(Integer id,ModelMap mmap){
        ExhibitionInfo exhibitionInfo = exhibitionInfoService.selectExhibitionInfoById(id);
        mmap.addAttribute("exhibitionInfo",exhibitionInfo);
        return "front/exhibitionDetail";
    }


    /**
     * 获取展览馆信息
     * @param id
     * @param mmap
     * @return
     */
    @RequestMapping(value = "/galleryDetail")
    public String galleryInfo(Integer id,ModelMap mmap){
        GalleryInfo galleryInfo = galleryInfoService.selectGalleryInfoById(id);
        mmap.addAttribute("galleryInfo",galleryInfo);
        return "front/galleryDetail";
    }


    @RequestMapping(value = "/add")
    public String add(Integer id,ModelMap mmap){
        mmap.addAttribute("id",id);
        return "/portal/appointAdd";
    }


    /**
     * 分页列表查询
     * @param exhibitionInfo
     * @return 返回DataGridResultInfo
     */
    @RequestMapping("/list")
    @ResponseBody
    public DataGridResultInfo list(ExhibitionInfo exhibitionInfo) {
        startPage();
        //编写查询条件
        exhibitionInfo.setIsShow(SysFlagStatusEnum.ZERO.getKey());
        List<ExhibitionInfo> list = exhibitionInfoService.selectExhibitionInfoList(exhibitionInfo);
        return getDataTable(list);
    }

}
